package com.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.admin.dao.AdminDao;
import com.shop.domain.BuyCommand;

@Controller
public class AdminWayDetailController {
	@Autowired
	private AdminDao adminDao;
	
	@RequestMapping(value="/shop/adminWayDetail.do",method=RequestMethod.GET)
	public ModelAndView process(@RequestParam("b_code")String b_code){
		
		List<BuyCommand> wayDetailList = adminDao.selectAdminWayDetail(b_code);
		
		ModelAndView mav = new ModelAndView();
		mav.setViewName("adminWayDetail");
		mav.addObject("wayDetailList", wayDetailList);
		mav.addObject("b_code", b_code);
		return mav;
	}
	
	@RequestMapping(value="/shop/adminWayDetail.do",method=RequestMethod.POST)
	public String submit(BuyCommand buyCommand){
		
		adminDao.updateAdminWay(buyCommand);
		
		return "redirect:/shop/adminWayList.do";
	}
	
}
